library(dplyr)
#library(psych) #for pairs.panels, but could use other packages, e.g. GGalley
library(lavaan)
library(semPlot)
library(DiagrammeR)
library(tidyr)
library(ggplot2)
combined=read.csv("data/annual_averages/annual_data_compiled_regions.csv",stringsAsFactors = F)
cnames=read.csv("analysis/column_names_region.csv", stringsAsFactors = F)
dsub=filter(combined, Year>=1975) %>% arrange(Region,Year)
focaldata=dsub[,cnames$Datacolumn]
fvars=cnames$Shortname
colnames(focaldata)=fvars
regions=unique(focaldata$region)
regionorder=c("West","North","South")
years=1975:2021
focaldata$tzoop=focaldata$hcope+focaldata$clad+focaldata$mysid+focaldata$pcope
focaldata$hzoop=focaldata$hcope+focaldata$clad
focaldata$pzoop=focaldata$mysid+focaldata$pcope
fvars=c(fvars,"tzoop","hzoop","pzoop")
cnames=rbind(cnames,data.frame(Longname=NA,Shortname=c("tzoop","hzoop","pzoop"),
Diagramname=c("Total Zooplankton\nBiomass",
"Total Herbivorous\nZooplankton",
"Total Predatory\nZooplankton"),
Datacolumn=NA,Log=c("yes","yes","yes")))
#focal variables
varnames=c("temp", "flow","nitrate","ammonia","dophos","chla","hcope","clad","amphi","pcope","mysid","potam","corbic","sside","estfish_bsot","estfish_bsmt","tzoop","hzoop","pzoop")
source("analysis/myLavaanPlot.r")
Log transform, scale
#log transform
logvars=fvars[cnames$Log=="yes"]
logtrans=function(x) {
x2=x[which(!is.na(x))]
if(any(x2==0)) {log(x+min(x2[which(x2>0)],na.rm=T))}
else {log(x)}
}
focaldatalog = focaldata %>%
mutate_at(logvars,logtrans)
#scale data
fdr0=focaldatalog
tvars=fvars[-(1:2)]
fdr=fdr0 %>% group_by(region) %>%
#lag
mutate_at(tvars,list("1"=lag)) %>%
#scale
mutate_at(-(1:2),scale) %>%
ungroup() %>%
as.data.frame()
#detrended data
fdr_dtr=fdr0 %>% group_by(region) %>%
#detrend
mutate_at(tvars,function(x) {
x<<-x
if(!all(is.na(x))) {
if((length(which(x==0))/length(x))<0.5) {
x2<<-x
x2[x2==0]=NA
res<<-residuals(lm(x2~years))
out=x
out[which(!is.na(x2))]=res
return(out)
} else {return(x)}
} else {return(x)}
}) %>%
#lag
mutate_at(tvars,list("1"=lag)) %>%
#scale
mutate_at(-(1:2),scale) %>%
ungroup() %>%
as.data.frame()
(only sig correlations shown… no correction for multiple comparisons)
Fish indices are not correlated in S and N!
With and without detrending.
#west has no ssides, corbic
# modwest='zoop=~hcope+mysid
# fish=~estfish_bsmt+estfish_bsot
# zoop~chla+potam+flow
# chla~potam+flow
# fish~zoop+flow
# '
modwest='chla~potam+flow
tzoop~chla+potam+flow
estfish_bsmt~tzoop+flow
estfish_bsot~tzoop+flow
'
modfitwest=sem(modwest, data=filter(fdr,region=="West"))
modfitwest_dtr=sem(modwest, data=filter(fdr_dtr,region=="West"))
summary(modfitwest, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 27 iterations
##
## Optimization method NLMINB
## Number of free parameters 14
##
## Used Total
## Number of observations 40 47
##
## Estimator ML
## Model Fit Test Statistic 4.813
## Degrees of freedom 4
## P-value (Chi-square) 0.307
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## potam -0.325 0.135 -2.407 0.016 -0.325 -0.380
## flow 0.098 0.131 0.748 0.454 0.098 0.118
## tzoop ~
## chla 0.831 0.096 8.676 0.000 0.831 0.792
## potam -0.154 0.088 -1.756 0.079 -0.154 -0.171
## flow -0.069 0.080 -0.867 0.386 -0.069 -0.080
## estfish_bsmt ~
## tzoop 0.626 0.115 5.457 0.000 0.626 0.568
## flow 0.386 0.100 3.874 0.000 0.386 0.403
## estfish_bsot ~
## tzoop 0.598 0.119 5.030 0.000 0.598 0.542
## flow 0.389 0.103 3.771 0.000 0.389 0.407
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt ~~
## .estfish_bsot 0.054 0.066 0.811 0.418 0.054 0.129
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.584 0.131 4.472 0.000 0.584 0.802
## .tzoop 0.215 0.048 4.472 0.000 0.215 0.267
## .estfish_bsmt 0.402 0.090 4.472 0.000 0.402 0.412
## .estfish_bsot 0.430 0.096 4.472 0.000 0.430 0.442
##
## R-Square:
## Estimate
## chla 0.198
## tzoop 0.733
## estfish_bsmt 0.588
## estfish_bsot 0.558
summary(modfitwest_dtr, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 24 iterations
##
## Optimization method NLMINB
## Number of free parameters 14
##
## Used Total
## Number of observations 40 47
##
## Estimator ML
## Model Fit Test Statistic 6.849
## Degrees of freedom 4
## P-value (Chi-square) 0.144
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## potam 0.032 0.162 0.196 0.844 0.032 0.034
## flow 0.215 0.160 1.341 0.180 0.215 0.229
## tzoop ~
## chla 0.837 0.105 8.009 0.000 0.837 0.795
## potam 0.026 0.107 0.247 0.805 0.026 0.026
## flow -0.020 0.108 -0.183 0.854 -0.020 -0.020
## estfish_bsmt ~
## tzoop 0.417 0.115 3.618 0.000 0.417 0.428
## flow 0.446 0.114 3.915 0.000 0.446 0.463
## estfish_bsot ~
## tzoop 0.379 0.121 3.139 0.002 0.379 0.383
## flow 0.455 0.119 3.824 0.000 0.455 0.467
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt ~~
## .estfish_bsot 0.046 0.089 0.519 0.604 0.046 0.082
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.879 0.197 4.472 0.000 0.879 0.953
## .tzoop 0.384 0.086 4.472 0.000 0.384 0.376
## .estfish_bsmt 0.534 0.119 4.472 0.000 0.534 0.548
## .estfish_bsot 0.584 0.131 4.472 0.000 0.584 0.585
##
## R-Square:
## Estimate
## chla 0.047
## tzoop 0.624
## estfish_bsmt 0.452
## estfish_bsot 0.415
# par(mfrow=c(1,2))
# semPaths(modfitwest, "std", edge.label.cex = 1, residuals = F)
# semPaths(modfitwest, "par", edge.label.cex = 1, residuals = F)
labelswest <- createLabels(modfitwest, cnames)
# residuals(modfitwest)
# modificationindices(modfitwest)
# modnorth='zoop=~hcope+mysid
# #fish=~estfish_bsmt+estfish_bsot
# zoop~chla+potam+flow
# chla~potam+flow
# estfish_bsmt~zoop+flow
# estfish_bsot~zoop+flow
# '
# modnorth='zoop=~clad
# zoop~chla+corbic+potam+flow
# chla~corbic+potam+flow
# estfish_bsmt~zoop+flow+sside+chla
# estfish_bsot~zoop+flow+sside+chla
# '
modnorth='chla~corbic+potam+flow
tzoop~chla+corbic+potam+flow
estfish_bsmt~tzoop+flow+chla
estfish_bsot~tzoop+flow
'
modfitnorth=sem(modnorth, data=filter(fdr,region=="North"))
modfitnorth_dtr=sem(modnorth, data=filter(fdr_dtr,region=="North"))
summary(modfitnorth, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 22 iterations
##
## Optimization method NLMINB
## Number of free parameters 17
##
## Used Total
## Number of observations 40 47
##
## Estimator ML
## Model Fit Test Statistic 1.857
## Degrees of freedom 5
## P-value (Chi-square) 0.868
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## corbic 0.358 0.132 2.718 0.007 0.358 0.422
## potam -0.121 0.143 -0.844 0.399 -0.121 -0.140
## flow 0.022 0.138 0.159 0.874 0.022 0.026
## tzoop ~
## chla 0.681 0.112 6.072 0.000 0.681 0.614
## corbic 0.414 0.102 4.069 0.000 0.414 0.440
## potam 0.075 0.103 0.735 0.463 0.075 0.078
## flow -0.351 0.098 -3.586 0.000 -0.351 -0.370
## estfish_bsmt ~
## tzoop 0.033 0.188 0.175 0.861 0.033 0.032
## flow 0.040 0.130 0.304 0.761 0.040 0.041
## chla 0.694 0.215 3.227 0.001 0.694 0.614
## estfish_bsot ~
## tzoop 0.468 0.135 3.476 0.001 0.468 0.470
## flow 0.251 0.128 1.968 0.049 0.251 0.266
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt ~~
## .estfish_bsot 0.025 0.098 0.256 0.798 0.025 0.040
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.562 0.126 4.472 0.000 0.562 0.737
## .tzoop 0.283 0.063 4.472 0.000 0.283 0.301
## .estfish_bsmt 0.565 0.126 4.472 0.000 0.565 0.579
## .estfish_bsot 0.677 0.151 4.472 0.000 0.677 0.727
##
## R-Square:
## Estimate
## chla 0.263
## tzoop 0.699
## estfish_bsmt 0.421
## estfish_bsot 0.273
summary(modfitnorth_dtr, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 23 iterations
##
## Optimization method NLMINB
## Number of free parameters 17
##
## Used Total
## Number of observations 40 47
##
## Estimator ML
## Model Fit Test Statistic 2.521
## Degrees of freedom 5
## P-value (Chi-square) 0.773
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## corbic 0.315 0.162 1.940 0.052 0.315 0.311
## potam 0.066 0.153 0.431 0.667 0.066 0.070
## flow 0.105 0.169 0.619 0.536 0.105 0.108
## tzoop ~
## chla 0.710 0.097 7.337 0.000 0.710 0.679
## corbic 0.317 0.104 3.049 0.002 0.317 0.299
## potam 0.086 0.094 0.920 0.358 0.086 0.087
## flow -0.460 0.104 -4.414 0.000 -0.460 -0.454
## estfish_bsmt ~
## tzoop 0.356 0.181 1.972 0.049 0.356 0.373
## flow 0.204 0.135 1.507 0.132 0.204 0.211
## chla 0.333 0.187 1.784 0.074 0.333 0.334
## estfish_bsot ~
## tzoop 0.228 0.149 1.528 0.126 0.228 0.238
## flow 0.225 0.151 1.492 0.136 0.225 0.232
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt ~~
## .estfish_bsot 0.085 0.109 0.776 0.438 0.085 0.124
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.846 0.189 4.472 0.000 0.846 0.871
## .tzoop 0.317 0.071 4.472 0.000 0.317 0.298
## .estfish_bsmt 0.526 0.118 4.472 0.000 0.526 0.542
## .estfish_bsot 0.892 0.199 4.472 0.000 0.892 0.916
##
## R-Square:
## Estimate
## chla 0.129
## tzoop 0.702
## estfish_bsmt 0.458
## estfish_bsot 0.084
# par(mfrow=c(1,2))
# semPaths(modfitnorth, "std", edge.label.cex = 1, residuals = F)
# semPaths(modfitnorth, "par", edge.label.cex = 1, residuals = F)
labelsnorth <- createLabels(modfitnorth, cnames)
# residuals(modfitnorth)
# modificationindices(modfitnorth)
#no potam
# modsouth='zoop=~hcope+mysid
# #fish=~estfish_bsmt+estfish_bsot
# zoop~chla+corbic+flow
# chla~corbic+flow
# estfish_bsmt~zoop+flow
# estfish_bsot~zoop+flow
# '
modsouth='chla~corbic+flow
tzoop~chla+corbic+flow
estfish_bsmt~tzoop+flow+corbic
estfish_bsot~tzoop+flow+corbic
'
modfitsouth=sem(modsouth, data=filter(fdr,region=="South"))
modfitsouth_dtr=sem(modsouth, data=filter(fdr_dtr,region=="South"))
summary(modfitsouth, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 20 iterations
##
## Optimization method NLMINB
## Number of free parameters 16
##
## Used Total
## Number of observations 40 47
##
## Estimator ML
## Model Fit Test Statistic 1.175
## Degrees of freedom 2
## P-value (Chi-square) 0.556
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## corbic 0.446 0.154 2.902 0.004 0.446 0.436
## flow -0.014 0.147 -0.093 0.926 -0.014 -0.014
## tzoop ~
## chla 0.677 0.095 7.107 0.000 0.677 0.705
## corbic 0.242 0.102 2.371 0.018 0.242 0.246
## flow -0.138 0.088 -1.559 0.119 -0.138 -0.147
## estfish_bsmt ~
## tzoop -0.008 0.164 -0.052 0.959 -0.008 -0.008
## flow -0.020 0.140 -0.142 0.887 -0.020 -0.021
## corbic 0.491 0.170 2.896 0.004 0.491 0.496
## estfish_bsot ~
## tzoop 0.184 0.150 1.231 0.218 0.184 0.191
## flow -0.175 0.128 -1.366 0.172 -0.175 -0.193
## corbic 0.423 0.155 2.727 0.006 0.423 0.446
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt ~~
## .estfish_bsot 0.004 0.108 0.035 0.972 0.004 0.006
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.846 0.189 4.472 0.000 0.846 0.813
## .tzoop 0.307 0.069 4.472 0.000 0.307 0.320
## .estfish_bsmt 0.745 0.167 4.472 0.000 0.745 0.765
## .estfish_bsot 0.623 0.139 4.472 0.000 0.623 0.697
##
## R-Square:
## Estimate
## chla 0.187
## tzoop 0.680
## estfish_bsmt 0.235
## estfish_bsot 0.303
summary(modfitsouth_dtr, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 15 iterations
##
## Optimization method NLMINB
## Number of free parameters 16
##
## Used Total
## Number of observations 40 47
##
## Estimator ML
## Model Fit Test Statistic 0.825
## Degrees of freedom 2
## P-value (Chi-square) 0.662
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## corbic 0.160 0.164 0.973 0.330 0.160 0.157
## flow -0.032 0.158 -0.206 0.837 -0.032 -0.033
## tzoop ~
## chla 0.639 0.112 5.708 0.000 0.639 0.642
## corbic 0.200 0.117 1.707 0.088 0.200 0.198
## flow -0.188 0.112 -1.685 0.092 -0.188 -0.193
## estfish_bsmt ~
## tzoop -0.223 0.153 -1.460 0.144 -0.223 -0.229
## flow -0.084 0.149 -0.566 0.571 -0.084 -0.089
## corbic 0.343 0.158 2.168 0.030 0.343 0.347
## estfish_bsot ~
## tzoop 0.082 0.146 0.562 0.574 0.082 0.085
## flow -0.220 0.142 -1.549 0.121 -0.220 -0.236
## corbic 0.349 0.151 2.316 0.021 0.349 0.360
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt ~~
## .estfish_bsot -0.056 0.130 -0.429 0.668 -0.056 -0.068
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 1.010 0.226 4.472 0.000 1.010 0.977
## .tzoop 0.506 0.113 4.472 0.000 0.506 0.494
## .estfish_bsmt 0.857 0.192 4.472 0.000 0.857 0.879
## .estfish_bsot 0.781 0.175 4.472 0.000 0.781 0.829
##
## R-Square:
## Estimate
## chla 0.023
## tzoop 0.506
## estfish_bsmt 0.121
## estfish_bsot 0.171
# par(mfrow=c(1,2))
# semPaths(modfitsouth, "std", edge.label.cex = 1, residuals = F)
# semPaths(modfitsouth, "par", edge.label.cex = 1, residuals = F)
labelssouth <- createLabels(modfitsouth, cnames)
# residuals(modfitsouth)
# modificationindices(modfitsouth)
Original units
West
North
South
Detrended
West
North
South
With and without detrending.
#west has no ssides, corbic
modwest='chla~potam
potam~flow
hzoop~chla+potam+flow
pzoop~chla+potam+flow+hzoop
estfish_bsmt~hzoop+pzoop+flow
estfish_bsot~hzoop+pzoop+flow
'
modfitwest=sem(modwest, data=filter(fdr,region=="West"))
modfitwest_dtr=sem(modwest, data=filter(fdr_dtr,region=="West"))
summary(modfitwest, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 33 iterations
##
## Optimization method NLMINB
## Number of free parameters 22
##
## Used Total
## Number of observations 40 47
##
## Estimator ML
## Model Fit Test Statistic 6.190
## Degrees of freedom 5
## P-value (Chi-square) 0.288
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## potam -0.370 0.122 -3.036 0.002 -0.370 -0.433
## potam ~
## flow -0.430 0.137 -3.133 0.002 -0.430 -0.444
## hzoop ~
## chla 0.665 0.103 6.463 0.000 0.665 0.678
## potam -0.142 0.096 -1.478 0.139 -0.142 -0.170
## flow 0.085 0.086 0.987 0.323 0.085 0.104
## pzoop ~
## chla 0.498 0.127 3.924 0.000 0.498 0.481
## potam -0.057 0.085 -0.673 0.501 -0.057 -0.065
## flow -0.209 0.075 -2.793 0.005 -0.209 -0.244
## hzoop 0.476 0.136 3.491 0.000 0.476 0.451
## estfish_bsmt ~
## hzoop 0.010 0.215 0.047 0.962 0.010 0.009
## pzoop 0.629 0.194 3.250 0.001 0.629 0.572
## flow 0.455 0.109 4.160 0.000 0.455 0.483
## estfish_bsot ~
## hzoop 0.271 0.223 1.220 0.223 0.271 0.234
## pzoop 0.394 0.200 1.967 0.049 0.394 0.358
## flow 0.392 0.113 3.460 0.001 0.392 0.416
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt ~~
## .estfish_bsot 0.055 0.065 0.843 0.399 0.055 0.134
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.592 0.132 4.472 0.000 0.592 0.813
## .potam 0.801 0.179 4.472 0.000 0.801 0.803
## .hzoop 0.251 0.056 4.472 0.000 0.251 0.358
## .pzoop 0.187 0.042 4.472 0.000 0.187 0.239
## .estfish_bsmt 0.396 0.088 4.472 0.000 0.396 0.419
## .estfish_bsot 0.424 0.095 4.472 0.000 0.424 0.448
##
## R-Square:
## Estimate
## chla 0.187
## potam 0.197
## hzoop 0.642
## pzoop 0.761
## estfish_bsmt 0.581
## estfish_bsot 0.552
summary(modfitwest_dtr, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 25 iterations
##
## Optimization method NLMINB
## Number of free parameters 22
##
## Used Total
## Number of observations 40 47
##
## Estimator ML
## Model Fit Test Statistic 10.015
## Degrees of freedom 5
## P-value (Chi-square) 0.075
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## potam -0.061 0.150 -0.409 0.682 -0.061 -0.065
## potam ~
## flow -0.423 0.141 -2.996 0.003 -0.423 -0.428
## hzoop ~
## chla 0.669 0.109 6.121 0.000 0.669 0.681
## potam -0.048 0.115 -0.420 0.675 -0.048 -0.052
## flow 0.138 0.113 1.217 0.223 0.138 0.150
## pzoop ~
## chla 0.417 0.121 3.446 0.001 0.417 0.468
## potam 0.068 0.092 0.739 0.460 0.068 0.080
## flow -0.163 0.092 -1.772 0.076 -0.163 -0.195
## hzoop 0.347 0.126 2.752 0.006 0.347 0.382
## estfish_bsmt ~
## hzoop 0.028 0.174 0.161 0.872 0.028 0.028
## pzoop 0.483 0.190 2.539 0.011 0.483 0.432
## flow 0.498 0.123 4.061 0.000 0.498 0.532
## estfish_bsot ~
## hzoop 0.232 0.181 1.276 0.202 0.232 0.224
## pzoop 0.259 0.198 1.308 0.191 0.259 0.228
## flow 0.441 0.127 3.461 0.001 0.441 0.465
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt ~~
## .estfish_bsot 0.047 0.087 0.542 0.588 0.047 0.086
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.919 0.205 4.472 0.000 0.919 0.996
## .potam 0.836 0.187 4.472 0.000 0.836 0.817
## .hzoop 0.439 0.098 4.472 0.000 0.439 0.494
## .pzoop 0.278 0.062 4.472 0.000 0.278 0.380
## .estfish_bsmt 0.529 0.118 4.472 0.000 0.529 0.575
## .estfish_bsot 0.573 0.128 4.472 0.000 0.573 0.605
##
## R-Square:
## Estimate
## chla 0.004
## potam 0.183
## hzoop 0.506
## pzoop 0.620
## estfish_bsmt 0.425
## estfish_bsot 0.395
labelswest <- createLabels(modfitwest, cnames)
# residuals(modfitwest)
# modificationindices(modfitwest)
modnorth='chla~corbic+potam
potam~flow
corbic~flow
hzoop~chla+corbic+potam+flow
pzoop~chla+corbic+potam+flow+hzoop
estfish_bsmt~hzoop+pzoop+flow
estfish_bsot~hzoop+pzoop+flow
'
modfitnorth=sem(modnorth, data=filter(fdr,region=="North"))
modfitnorth_dtr=sem(modnorth, data=filter(fdr_dtr,region=="North"))
summary(modfitnorth, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 26 iterations
##
## Optimization method NLMINB
## Number of free parameters 27
##
## Used Total
## Number of observations 40 47
##
## Estimator ML
## Model Fit Test Statistic 13.630
## Degrees of freedom 8
## P-value (Chi-square) 0.092
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## corbic 0.363 0.118 3.086 0.002 0.363 0.435
## potam -0.130 0.120 -1.083 0.279 -0.130 -0.153
## potam ~
## flow -0.498 0.134 -3.708 0.000 -0.498 -0.506
## corbic ~
## flow 0.398 0.146 2.721 0.007 0.398 0.395
## hzoop ~
## chla 0.283 0.158 1.796 0.072 0.283 0.275
## corbic 0.319 0.138 2.316 0.021 0.319 0.370
## potam 0.086 0.138 0.626 0.531 0.086 0.098
## flow -0.282 0.143 -1.971 0.049 -0.282 -0.325
## pzoop ~
## chla 0.673 0.099 6.826 0.000 0.673 0.593
## corbic 0.332 0.088 3.762 0.000 0.332 0.350
## potam 0.041 0.083 0.489 0.625 0.041 0.042
## flow -0.346 0.090 -3.843 0.000 -0.346 -0.363
## hzoop 0.222 0.095 2.336 0.020 0.222 0.202
## estfish_bsmt ~
## hzoop -0.043 0.184 -0.236 0.813 -0.043 -0.039
## pzoop 0.541 0.166 3.266 0.001 0.541 0.536
## flow 0.249 0.129 1.923 0.055 0.249 0.258
## estfish_bsot ~
## hzoop 0.142 0.185 0.765 0.444 0.142 0.130
## pzoop 0.360 0.167 2.151 0.031 0.360 0.365
## flow 0.278 0.131 2.127 0.033 0.278 0.295
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt ~~
## .estfish_bsot 0.033 0.109 0.303 0.762 0.033 0.048
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.563 0.126 4.472 0.000 0.563 0.761
## .potam 0.754 0.169 4.472 0.000 0.754 0.744
## .corbic 0.893 0.200 4.472 0.000 0.893 0.844
## .hzoop 0.559 0.125 4.472 0.000 0.559 0.712
## .pzoop 0.203 0.045 4.472 0.000 0.203 0.213
## .estfish_bsmt 0.681 0.152 4.472 0.000 0.681 0.702
## .estfish_bsot 0.695 0.155 4.472 0.000 0.695 0.747
##
## R-Square:
## Estimate
## chla 0.239
## potam 0.256
## corbic 0.156
## hzoop 0.288
## pzoop 0.787
## estfish_bsmt 0.298
## estfish_bsot 0.253
summary(modfitnorth_dtr, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 22 iterations
##
## Optimization method NLMINB
## Number of free parameters 27
##
## Used Total
## Number of observations 40 47
##
## Estimator ML
## Model Fit Test Statistic 6.959
## Degrees of freedom 8
## P-value (Chi-square) 0.541
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## corbic 0.353 0.152 2.325 0.020 0.353 0.349
## potam 0.028 0.141 0.195 0.845 0.028 0.029
## potam ~
## flow -0.421 0.148 -2.841 0.004 -0.421 -0.410
## corbic ~
## flow 0.371 0.139 2.657 0.008 0.371 0.387
## hzoop ~
## chla 0.214 0.131 1.628 0.103 0.214 0.242
## corbic 0.067 0.143 0.472 0.637 0.067 0.076
## potam 0.006 0.127 0.047 0.963 0.006 0.007
## flow -0.373 0.140 -2.666 0.008 -0.373 -0.437
## pzoop ~
## chla 0.672 0.094 7.115 0.000 0.672 0.632
## corbic 0.355 0.100 3.551 0.000 0.355 0.329
## potam 0.121 0.089 1.368 0.171 0.121 0.121
## flow -0.414 0.106 -3.916 0.000 -0.414 -0.403
## hzoop 0.095 0.110 0.858 0.391 0.095 0.078
## estfish_bsmt ~
## hzoop 0.213 0.160 1.331 0.183 0.213 0.188
## pzoop 0.510 0.128 3.992 0.000 0.510 0.543
## flow 0.367 0.131 2.798 0.005 0.367 0.380
## estfish_bsot ~
## hzoop -0.123 0.194 -0.635 0.526 -0.123 -0.108
## pzoop 0.280 0.154 1.812 0.070 0.280 0.298
## flow 0.198 0.159 1.245 0.213 0.198 0.204
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt ~~
## .estfish_bsot 0.130 0.116 1.120 0.263 0.130 0.180
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.854 0.191 4.472 0.000 0.854 0.880
## .potam 0.911 0.204 4.472 0.000 0.911 0.832
## .corbic 0.806 0.180 4.472 0.000 0.806 0.850
## .hzoop 0.588 0.131 4.472 0.000 0.588 0.781
## .pzoop 0.286 0.064 4.472 0.000 0.286 0.260
## .estfish_bsmt 0.596 0.133 4.472 0.000 0.596 0.616
## .estfish_bsot 0.873 0.195 4.472 0.000 0.873 0.899
##
## R-Square:
## Estimate
## chla 0.120
## potam 0.168
## corbic 0.150
## hzoop 0.219
## pzoop 0.740
## estfish_bsmt 0.384
## estfish_bsot 0.101
labelsnorth <- createLabels(modfitnorth, cnames)
# residuals(modfitnorth)
# modificationindices(modfitnorth)
#no potam
modsouth='chla~corbic
corbic~flow
hzoop~chla+corbic+flow
pzoop~chla+corbic+flow+hzoop
estfish_bsmt~hzoop+pzoop+flow+corbic
estfish_bsot~hzoop+pzoop+flow+corbic
'
modfitsouth=sem(modsouth, data=filter(fdr,region=="South"))
modfitsouth_dtr=sem(modsouth, data=filter(fdr_dtr,region=="South"))
summary(modfitsouth, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 24 iterations
##
## Optimization method NLMINB
## Number of free parameters 24
##
## Used Total
## Number of observations 40 47
##
## Estimator ML
## Model Fit Test Statistic 0.149
## Degrees of freedom 3
## P-value (Chi-square) 0.985
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## corbic 0.442 0.146 3.027 0.002 0.442 0.432
## corbic ~
## flow 0.301 0.143 2.101 0.036 0.301 0.315
## hzoop ~
## chla 0.526 0.120 4.393 0.000 0.526 0.536
## corbic 0.329 0.128 2.572 0.010 0.329 0.327
## flow -0.209 0.111 -1.883 0.060 -0.209 -0.218
## pzoop ~
## chla 0.642 0.120 5.359 0.000 0.642 0.685
## corbic 0.015 0.114 0.135 0.893 0.015 0.016
## flow -0.047 0.095 -0.497 0.619 -0.047 -0.052
## hzoop 0.151 0.130 1.164 0.244 0.151 0.159
## estfish_bsmt ~
## hzoop -0.335 0.180 -1.864 0.062 -0.335 -0.339
## pzoop 0.319 0.172 1.852 0.064 0.319 0.309
## flow -0.063 0.135 -0.466 0.641 -0.063 -0.066
## corbic 0.552 0.162 3.406 0.001 0.552 0.557
## estfish_bsot ~
## hzoop 0.104 0.175 0.592 0.554 0.104 0.110
## pzoop 0.014 0.168 0.082 0.934 0.014 0.014
## flow -0.178 0.131 -1.356 0.175 -0.178 -0.197
## corbic 0.460 0.158 2.906 0.004 0.460 0.484
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt ~~
## .estfish_bsot 0.013 0.103 0.125 0.900 0.013 0.020
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.846 0.189 4.472 0.000 0.846 0.814
## .corbic 0.894 0.200 4.472 0.000 0.894 0.901
## .hzoop 0.485 0.108 4.472 0.000 0.485 0.484
## .pzoop 0.328 0.073 4.472 0.000 0.328 0.359
## .estfish_bsmt 0.670 0.150 4.472 0.000 0.670 0.687
## .estfish_bsot 0.638 0.143 4.472 0.000 0.638 0.714
##
## R-Square:
## Estimate
## chla 0.186
## corbic 0.099
## hzoop 0.516
## pzoop 0.641
## estfish_bsmt 0.313
## estfish_bsot 0.286
summary(modfitsouth_dtr, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 19 iterations
##
## Optimization method NLMINB
## Number of free parameters 24
##
## Used Total
## Number of observations 40 47
##
## Estimator ML
## Model Fit Test Statistic 0.064
## Degrees of freedom 3
## P-value (Chi-square) 0.996
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## corbic 0.151 0.159 0.951 0.341 0.151 0.149
## corbic ~
## flow 0.238 0.147 1.614 0.107 0.238 0.247
## hzoop ~
## chla 0.483 0.125 3.857 0.000 0.483 0.484
## corbic 0.312 0.131 2.371 0.018 0.312 0.307
## flow -0.237 0.125 -1.892 0.059 -0.237 -0.242
## pzoop ~
## chla 0.579 0.139 4.174 0.000 0.579 0.572
## corbic -0.094 0.133 -0.707 0.480 -0.094 -0.091
## flow -0.085 0.123 -0.686 0.493 -0.085 -0.086
## hzoop 0.186 0.149 1.245 0.213 0.186 0.184
## estfish_bsmt ~
## hzoop -0.335 0.174 -1.925 0.054 -0.335 -0.344
## pzoop 0.085 0.159 0.534 0.593 0.085 0.089
## flow -0.109 0.147 -0.743 0.457 -0.109 -0.115
## corbic 0.399 0.161 2.482 0.013 0.399 0.404
## estfish_bsot ~
## hzoop 0.105 0.169 0.623 0.533 0.105 0.110
## pzoop -0.106 0.154 -0.685 0.493 -0.106 -0.112
## flow -0.227 0.143 -1.587 0.112 -0.227 -0.243
## corbic 0.341 0.156 2.183 0.029 0.341 0.351
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .estfish_bsmt ~~
## .estfish_bsot -0.052 0.127 -0.412 0.680 -0.052 -0.065
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 1.011 0.226 4.472 0.000 1.011 0.978
## .corbic 0.939 0.210 4.472 0.000 0.939 0.939
## .hzoop 0.635 0.142 4.472 0.000 0.635 0.615
## .pzoop 0.567 0.127 4.472 0.000 0.567 0.535
## .estfish_bsmt 0.823 0.184 4.472 0.000 0.823 0.844
## .estfish_bsot 0.775 0.173 4.472 0.000 0.775 0.823
##
## R-Square:
## Estimate
## chla 0.022
## corbic 0.061
## hzoop 0.385
## pzoop 0.465
## estfish_bsmt 0.156
## estfish_bsot 0.177
labelssouth <- createLabels(modfitsouth, cnames)
# residuals(modfitsouth)
# modificationindices(modfitsouth)
Original units
West
North
South
Detrended
West
North
South